package com.dfec.water.dao;

import com.dfec.framework.mybatis.core.mapper.BaseMapperX;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dfec.water.entity.YdbForecastListEntity;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 预测信息Dao接口
 *
 * @author df
 * @date Thu Jan 23 10:24:59 CST 2025
 */
@Mapper
public interface YdbForecastListDao extends BaseMapperX<YdbForecastListEntity> {

    /**
     * description:分页查询
     *
     * @param pageParam 分页参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    default PageUtils selectPage(PageParam<YdbForecastListEntity> pageParam) {
        YdbForecastListEntity entity = pageParam.getEntity() == null ? new YdbForecastListEntity() :pageParam.getEntity();
        return this.selectPage(pageParam, dealParams(entity));
    }


    /**
     * 不带分页查询
     * @param YdbForecastListEntity
     * @return
     */
    default  List<YdbForecastListEntity> selectAll(YdbForecastListEntity YdbForecastListEntity){
        return this.selectList(dealParams(YdbForecastListEntity));
    }

    /**
     * description:查询条件拼接
     *
     * @param entity 参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    public default LambdaQueryWrapperX<YdbForecastListEntity> dealParams(YdbForecastListEntity entity){
        return new LambdaQueryWrapperX<YdbForecastListEntity>()
                .likeIfPresent(YdbForecastListEntity::getName, entity.getName())
                .eqIfPresent(YdbForecastListEntity::getForecastId, entity.getForecastId())
                ;
    }



}
